var HuaZiGe = {
    name:'huazi',
    age:20,
    sex: 'boy',
    smoke: function(){
        console.log('I am smoking! cool!');
        this.health--
    },
    drink: function(){
        console.log('I am drink');
        this.health++
    },
    health: 100,
}


// console.log(HuaZiGe.health);

//增
HuaZiGe.boyFriend = 'lai'

//查
// console.log(HuaZiGe.boyFriend);

//改
// HuaZiGe.sex = 'girl'
// console.log(HuaZiGe.sex);

//删
delete HuaZiGe.sex
console.log(HuaZiGe.sex); //undefined?

// 当访问一个不存在的变量时会报错，当访问一个对象中不存在的属性就为undefined！为什么？



//对象的创建
// 1. var obj = {}    // plainObject 对象字面量或对象直接量
// 2. 构造函数
    // 1) 系统自带的构造函数  Object()
    // 2) 自定义

// var obj = new Object()   // var obj = {}  没有区别
// obj.name = '家君'
// obj.sex = 'boy'


// 3)
function Car(color) {
   this.name = 'BMW'
   this.health = '1400'
   this.long = '4900'
   this.weight = 1000
   this.health = 100
   this.run = function(){
       this.health--
   } 
   this.color = color
}

// var car1 = new Car() //实例化
// var car2 = new Car()
// //构造函数实例化出来的对象是相互独立的
// console.log(car1 === car2); //false


var car1 = new Car('pink') 
var car2 = new Car('red')

